package com.dotools.base;

import java.io.File;
import android.os.Environment;
import com.dotools.theme.ThemeConstance;
import com.dotools.utils.DeviceUtil;
import com.dotools.utils.Utilities;


public class PathConstance {

    public static String BASE_PATH;

    public static String DOWNLOAD_PATH;

    public static String TEMP_PATH;

    public static String IMAGE_PATH;
    
    public static String DATA_PATH;
    
    public static void initPath(){
        long availableSDCardSpace = DeviceUtil.getSdCardHaveSize();
        // 获取SD卡可用空间
        if (availableSDCardSpace != -1L) { // 如果存在SD卡
            PathConstance.BASE_PATH = Environment.getExternalStorageDirectory() + File.separator + "iDoLockscreen";
            ThemeConstance.THEME_ZIP_PATH = PathConstance.BASE_PATH + File.separator + "themeZip/";
        } else if (DeviceUtil.getSdCardHaveSize() != -1) {
            PathConstance.BASE_PATH = Utilities.getApplicationContext().getFilesDir().getPath() + File.separator + "iDoLockscreen";
        } else { // sd卡不存在
            PathConstance.BASE_PATH = Utilities.getApplicationContext().getFilesDir().getPath() + File.separator + "iDoLockscreen";
        }
        PathConstance.DOWNLOAD_PATH = PathConstance.BASE_PATH + File.separator + "download/";
        PathConstance.TEMP_PATH = PathConstance.BASE_PATH + File.separator + "temp/";
        PathConstance.IMAGE_PATH = PathConstance.BASE_PATH + File.separator + "image/";
        PathConstance.DATA_PATH = PathConstance.BASE_PATH + File.separator + "data/";
        ThemeConstance.THEME_ZIP_PATH = PathConstance.BASE_PATH + File.separator + "themeZip/";

        File file = null;
        file = new File(PathConstance.BASE_PATH);
        if (!file.exists()) {
            file.mkdirs();
        }

        file = new File(PathConstance.DOWNLOAD_PATH);
        if (!file.exists()) {
            file.mkdirs();
        }

        file = new File(PathConstance.TEMP_PATH);
        if (!file.exists()) {
            file.mkdirs();
        }

        file = new File(PathConstance.IMAGE_PATH);
        if (!file.exists()) {
            file.mkdirs();
        }

        file = new File(PathConstance.DATA_PATH);
        if (!file.exists()) {
            file.mkdirs();
        }

        file = new File(ThemeConstance.THEME_ZIP_PATH);
        if (!file.exists()) {
            file.mkdirs();
        }
       
    }

}
